package com.star.carservice.client;

import com.baidu.location.BDLocation;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.LocationClientOption.LocationMode;
import com.star.carserviceapi.ClientApiFactory;
import com.star.carserviceapi.IClientApi;

import android.app.Application;

public class AppController extends Application {

	public static final String TAG = AppController.class.getSimpleName();

	private static AppController mInstance;

	public static synchronized AppController getInstance() {
		return mInstance;
	}

	private BDLocation mLastDBLocation = null;

	public BDLocation getLastDBLocation() {
		return mLastDBLocation;
	}

	public void setLastDBLocation(BDLocation lastDBLocation) {
		mLastDBLocation = lastDBLocation;
	}

	@Override
	public void onCreate() {
		super.onCreate();
		mInstance = this;
	}

	public LocationClient getLocationClientInstance() {
		LocationClient locationClient = new LocationClient(
				this.getApplicationContext());

		LocationClientOption option = new LocationClientOption();
		option.setLocationMode(LocationMode.Battery_Saving);// 设置定位模式

		// gcj02 bd09ll bd09
		option.setCoorType("bd09ll");// 返回的定位结果是百度经纬度，默认值gcj02

		option.setScanSpan(0);// 设置发起定位请求的间隔时间为5000ms
		option.setIsNeedAddress(true);

		locationClient.setLocOption(option);

		return locationClient;
	}

	public IClientApi getApi() {
		return ClientApiFactory.getInstance(mInstance);
	}

	/**************************** start 全局户缓存 *************************************/

	/**************************** end 全局户缓存 *************************************/

}
